
package com.util;

import java.lang.reflect.Field;

import javax.servlet.http.HttpServletRequest;

import com.vo.ActionForm;

/**
 * 
 * 项目名称：MVC  类名称：FormUtil 创建人：summer 创建时间：2014-12-17 上午09:42:56 修改人：summer
 * 修改时间：2014-12-17 上午09:42:56 修改备注：
 * 
 * @version
 * 
 */
public class FormUtil {


    public static ActionForm fillBean(String fromClsss, HttpServletRequest request) {
        ActionForm form = null;
        try {

            Class clazz = Class.forName(fromClsss);

            form = (ActionForm) clazz.newInstance();

            Field[] fieds = clazz.getDeclaredFields();

            for (Field f : fieds) {
                f.setAccessible(true);
                f.set(form, request.getParameter(f.getName()));
                f.setAccessible(false);
            }

        } catch (Exception e) {
            e.printStackTrace();
        }
        return form;
    }
}
